package com.tusuo.stds.util;

import android.content.Context;
import android.content.Intent;

import com.tusuo.stds.ui.account.AccountActivity_;
import com.tusuo.stds.ui.login.LoginActivity_;
import com.tusuo.stds.ui.login.ThirdLoginUserInfo;
import com.tusuo.stds.ui.main.MainActivity_;

import org.parceler.Parcels;

import myandroid.library.util.ApplicationHelper;

/**
 * @author J.Huang
 * @version 1.0
 *
 */

public class IntentUtils {
    public static void toLogin(Context context) {
        if (context != null) {
            Intent intent = new Intent();

            intent.setClass(context, LoginActivity_.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

            context.startActivity(intent);
//            activity.finish();
            ApplicationHelper.getInstance().clearActivity();
        }
    }

    public static void toMainActivity(Context context) {
        if (context != null) {
            Intent intent = new Intent();
            intent.setClass(context, MainActivity_.class);

            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

            context.startActivity(intent);
//            activity.finish();
            ApplicationHelper.getInstance().clearActivity();
        }
    }

    public static void toCurrentMainActivity(Context context) {
        if (context != null) {
            Intent intent = new Intent();
            intent.setClass(context, MainActivity_.class);

            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

            context.startActivity(intent);
//            activity.finish();
//            ApplicationHelper.getInstance().clearActivity();
        }
    }

    public static void toAccountActivity(Context context) {
        if (context != null) {
            Intent intent = new Intent();
            intent.setClass(context, AccountActivity_.class);

            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

            context.startActivity(intent);
        }
    }

    public static void toBindNewMainActivity(Context context, ThirdLoginUserInfo mThirdLoginUserInfo,boolean isNew) {
        if (context != null) {
            Intent intent = new Intent();
            intent.setClass(context, MainActivity_.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(ThirdLoginUserInfo.EXTRA_NAME, Parcels.wrap(mThirdLoginUserInfo));
            intent.putExtra("isNew",isNew);
            context.startActivity(intent);
        }
    }

}
